<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@include file="/resource/common/taglib.jspf"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>${SESSION_COMPANY}-系统用户管理</title>
<%@include file="/resource/common/jquery.jspf"%>
<%@include file="/resource/common/commonCss.jspf"%>
<%@include file="/resource/common/bootstrap.jspf"%>
<script type="text/javascript">

</script>
</head>
<body>
	<div id="body-wrapper">
		<div id="main-content">
			<div class="clear"></div>
			<div class="content-box-content">
				<div class="tab-content default-tab" id="tab1">
					<row>
						<div class="col-md-5 col-sm-5 col-xs-5">
							<div class="content-box-header">
								<h3 class="panel-title">个人资料</h3>
								<ul class="content-box-tabs">
									<a href="javascript:void(0)" onclick="add(0);" class="btn btn-success" style="padding-bottom: 0px;padding-top: 0px;line-height: 25px;margin-top: -5px;"><i class="fa fa-edit"></i>&nbsp;&nbsp;编辑资料</a>
									<a href="javascript:void(0)" onclick="updatePassword();" class="btn btn-info" style="padding-bottom: 0px;padding-top: 0px;line-height: 25px;margin-top: -5px;"><i class="fa fa-edit"></i>&nbsp;&nbsp;更改密码</a>
								</ul>
								<div class="clear"></div>
							</div>
							<table class="table table-bordered table-hover">
								<tbody>
									<tr>
										<th class="text-center">帐号</th>
										<td class="text-center">${entity.username}</td>
									</tr>
									<tr>
										<th class="text-center">联系人</th>
										<td class="text-center">${entity.contact}</td>
									</tr>
									<tr>
										<th class="text-center">电话</th>
										<td class="text-center">${entity.tel}</td>
									</tr>
									<tr>
										<th class="text-center">状态</th>
										<td class="text-center"><c:choose>
												<c:when test="${entity.enable==1}">活动中</c:when>
												<c:otherwise>已被禁用</c:otherwise>
											</c:choose>
										</td>
									</tr>
									<tr>
										<th class="text-center">注册时间</th>
										<td class="text-center"><fmt:formatDate
												value="${entity.ctime}" pattern="yyyy-MM-dd" /></td>
									</tr>
									<tr>
										<th class="text-center">修改时间</th>
										<td class="text-center"><fmt:formatDate
												value="${entity.utime}" pattern="yyyy-MM-dd" /></td>
									</tr>
									<tr>
										<th class="text-center">最后登陆时间</th>
										<td class="text-center"><fmt:formatDate
												value="${entity.ltime}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
									</tr>
									<tr>
										<th class="text-center">最后登陆IP</th>
										<td class="text-center">${entity.lip}</td>
									</tr>
								</tbody>
							</table>
						</div>
						<div class="col-md-5 col-sm-5 col-xs-5">
							
						</div>
					</row>
				</div>
			</div>
		</div>
	</div>
<script type="text/javascript">
function updatePassword(){
	var titles = "修改密码";
	top.layer.open({
	  type: 2,
	  title: titles,
	  shade: 0.5,//背景色深度
	  fixed: false, //不固定
	  maxmin: true,
	  shadeClose: false,//点击其它区域关闭
	  anim : 1,
	  content: 'updateSysUserPassword.do',
	  area: ['400px' , '330px'],
	  btn: ['确定' ,'关闭'], //只是为了演示
	  yes: function(index, layero){
		 var body = top.layer.getChildFrame('body', index);
		 var iframeWin = layero.find('iframe')[0];// 得到iframe页的窗口对像，执行iframe页的方法，iframeWin.method();
		 var value = iframeWin.contentWindow.doSubmit();
		 if(value){
		 	var result = 0;
			var count = 0;
			// 表单提交后，先延时1秒去取异步结果，如果还不成功，再延时3秒去取结果，正常的逻辑时间够了，如果是有大内容就得再回5秒或10秒
			var tmsg = top.layer.msg('数据开始刷新.......', {
				time : 100000,
				icon : 6
			});
			var tload = top.layer.load(0, {
				shade : [ 0.5, '#fff' ]
			}); // 0代表加载的风格，支持0-2
			 asyncSaveClose(iframeWin,index, result, 1000, count, tmsg, tload);
		 }
	  },
	  end: function(index){
		  top.layer.closeAll();
	  }
	});
}
function asyncSaveClose(iframeWin, index, result, time,count, tmsg, tload) {
	return setTimeout(function() {
		count++;
		result = iframeWin.contentWindow.asyncResult();
		if (result ==1) {
			top.layer.msg('更换密码刷新成功.需要重新登录......', {
				time : 2000,
				icon : 6
			});
			top.layer.close(index);
			top.layer.close(tmsg);
			top.layer.close(tload);
			setTimeout(function(){
				top.layer.msg('更换密码成功.马上重新登录......', {
					time : 1000,
					icon : 6
				});
				top.location = "logout.do";
			}, 1000);
		} else if(result ==-1){
			if (count > 5) {
				top.layer.alert('更换密码刷新失败....', {
					skin : 'layui-layer-lan',
					closeBtn : 0,
					anim : 4,
					icon : 5
				});
				top.layer.close(index);
				top.layer.close(tmsg);
				top.layer.close(tload);
			} else {
				asyncSaveClose(iframeWin,index, result, (time + 1000), count, tmsg, tload);
			}
		}else if(result==-110){
			top.layer.close(tload);
			top.layer.alert('访问服务器接口出错....', {
				skin : 'layui-layer-lan',
				closeBtn : 0,
				anim : 4,
				icon : 5
			});
		}else{
			top.layer.close(tload);
			var error = iframeWin.contentWindow.asyncResultError();
			top.layer.alert('操作失败。错误码：'+result+" 错误信息："+error, {
				skin : 'layui-layer-lan',
				closeBtn : 0,
				anim : 4,
				icon : 5
			});
		}
	}, time);
}
</script>
</body>
</html>
